package com.kakarote.hrm.controller;

import com.kakarote.core.common.Result;
import com.kakarote.core.entity.BasePage;
import com.kakarote.hrm.entity.PO.HrmRecruitReportLog;
import com.kakarote.hrm.entity.VO.RecruitReportLogVO;
import com.kakarote.hrm.service.IHrmRecruitReportLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static com.kakarote.core.common.enums.SystemCodeEnum.SYSTEM_ERROR;

/**
 * <p>
 * 招聘计划日志记录 前端控制器
 * </p>
 *
 * @author system
 * @since 2024-01-01
 */
@RestController
@RequestMapping("/hrmRecruitReportLog")
@Api(tags = "招聘管理-招聘计划日志")
public class HrmRecruitReportLogController {

    @Autowired
    private IHrmRecruitReportLogService reportLogService;

    @ApiOperation("添加招聘计划日志")
    @PostMapping("/addReportLog")
    public Result addReportLog(@Validated @RequestBody HrmRecruitReportLog reportLog) {
        boolean result = reportLogService.addReportLog(reportLog);
        return result ? Result.ok() : Result.error(SYSTEM_ERROR.getCode(), "添加失败");
    }

    @ApiOperation("根据计划id查询日志列表")
    @PostMapping("/queryByPlanId/{planId}")
    public Result<List<RecruitReportLogVO>> queryByPlanId(@PathVariable("planId") Long planId) {
        List<RecruitReportLogVO> list = reportLogService.queryByPlanId(planId);
        return Result.ok(list);
    }

    @ApiOperation("根据id查询日志详情")
    @PostMapping("/queryById/{planLogId}")
    public Result<HrmRecruitReportLog> queryById(@PathVariable("planLogId") Long planLogId) {
        HrmRecruitReportLog reportLog = reportLogService.queryById(planLogId);
        return Result.ok(reportLog);
    }

    @ApiOperation("删除日志")
    @PostMapping("/deleteById/{planLogId}")
    public Result deleteById(@PathVariable("planLogId") Long planLogId) {
        boolean result = reportLogService.removeById(planLogId);
        return result ? Result.ok() : Result.error(SYSTEM_ERROR.getCode(), "删除失败");
    }
}
